package jjn.acwing.algorithm_basic.chapter1.two_pointer;

import java.util.Scanner;

/**
 * @author Jjn
 * @since 2023-09-23 10:06
 */
public class Acwing2816 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int m = scanner.nextInt();
        int[] a = new int[n];
        int[] b = new int[m];
        for (int i = 0; i < n; i++) {
            a[i] = scanner.nextInt();
        }
        for (int i = 0; i < m; i++) {
            b[i] = scanner.nextInt();
        }
        int i = 0, j = 0;
        while (i < n && j < m) {
            if (a[i] == b [j]) {
                i++;
            }
            j++;
        }
        if (i == n) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}
